package demo_designPattern.chain.intercepterChain;

import java.util.LinkedList;
import java.util.List;

public class IntercepterChain implements Intercepter{
    List<Intercepter> chain = new  LinkedList<Intercepter>();
    
    public IntercepterChain addIntercepter(Intercepter intercepter){
	chain.add(intercepter);
	return this;
    }
    
    public List<Intercepter> moveIntercepter(Intercepter intercepter){
	chain.remove(intercepter);
	return this.chain;
    }
    
    public void startChain(Request req){
	for(Intercepter i : chain){
	    i.doIntercept(req);
	}
    }

    @Override
    public void doIntercept(Request req) {
	for(Intercepter i : chain){
	    i.doIntercept(req);
	}
    }
   
}
